<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of operation
 *
 * @author abdallah awwad wlsabeeh and abdallah abu khader
 */
if(isset ($_GET))
  {
$type=   $_GET['type'];  
$hegith= $_GET['hegith'];  
$width=  $_GET['width'];  
$quality=$_GET['quality'];  
operation::imgUploader($_FILES['pic'],'tmp/');
operation::convert($oldimg,$newImg,$width,$heigt,$qualty);
              
  }


class operation {
 
     
 function imgUploader($file,$path)
{
$allowedExts = array("jpg", "jpeg", "gif", "png");  
$extension = end(explode(".",$file["name"]));  
if ((($file["type"] == "image/gif")
|| ($file["type"] == "image/jpeg")
|| ($file["type"] == "image/pjpeg"))
&& in_array($extension, $allowedExts)){

$img=time().'.'.$extension;  
$path=$path.$img;

if(move_uploaded_file($file['tmp_name'], $path)) {
   return $img;
} else{
    echo "خطاء أثناء التحميل";
}  
    }
else{
        return null;   
}   
}

    
function convert($oldimg,$newImg,$width,$heigt,$qualty)
                {
 //الأمر التي سيتم تنفيذه على التيرمنال       
    echo $command="convert ".$oldimg." ".$newImg;
   
    exec($command, $output, $return_var);
   
   return  $output;
   
                }
}

?>
